home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / src / mail / pine3.96.tar.gz / pine3.96.tar / pine3.96 / pine / mailtrfc.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  1996-03-15  |  5KB  |  125 lines

  1. #!/bin/sh
  2. #
  3. # $Id: mailtrfc.sh,v 4.4 1996/03/15 07:13:42 hubert Exp $
  4. #
  5. #            T H E    P I N E    M A I L   S Y S T E M
  6. #
  7. #   Laurence Lundblade and Mike Seibel
  8. #   Networks and Distributed Computing
  9. #   Computing and Communications
  10. #   University of Washington
  11. #   Administration Building, AG-44
  12. #   Seattle, Washington, 98195, USA
  13. #   Internet: lgl@CAC.Washington.EDU
  14. #             mikes@CAC.Washington.EDU
  15. #
  16. #   Please address all bugs and comments to "pine-bugs@cac.washington.edu"
  17. #
  18. #
  19. #   Pine and Pico are registered trademarks of the University of Washington.
  20. #   No commercial use of these trademarks may be made without prior written
  21. #   permission of the University of Washington.
  22. #
  23. #   Pine, Pico, and Pilot software and its included text are Copyright
  24. #   1989-1996 by the University of Washington.
  25. #
  26. #   The full text of our legal notices is contained in the file called
  27. #   CPYRIGHT, included with this distribution.
  28. #
  29. #
  30. #   Pine is in part based on The Elm Mail System:
  31. #    ***********************************************************************
  32. #    *  The Elm Mail System  -  Revision: 2.13                             *
  33. #    *                                                                     *
  34. #    *             Copyright (c) 1986, 1987 Dave Taylor               *
  35. #    *             Copyright (c) 1988, 1989 USENET Community Trust    *
  36. #    ***********************************************************************
  37. #
  38.  
  39.  
  40. # mailtrfc.sh -- A shell script to analyze the mail traffic as logged in
  41. # /usr/spool/mqueue/syslog*. This currently as the University of Washington
  42. # domains wired in and needs to be made more general. Also, lots more
  43. # formats of message ID's could be added.
  44. #
  45.  
  46.  
  47.  
  48. org=`awk '/^domain/ {print $2}' < /etc/resolv.conf`
  49. domain=`echo $org | sed -e 's/^[^.]*\.//'`
  50. host=`hostname`".$org"
  51.  
  52. echo "Domain: $domain"
  53. echo "Organization: $org"
  54. echo "Hostname: $host"
  55.  
  56. sed -n -e '/message-id/s/^.*</</p' |
  57. awk 'BEGIN {mailers[0] =  "Other";
  58.             mailers[1] =  "Pine";
  59.             mailers[2] =  "MailManager";
  60.             mailers[3] =  "sendmail";
  61.             mailers[4] =  "BITNET";
  62.             mailers[5] =  "? news ?";
  63.             mailers[6] =  "Sprint";
  64.             mailers[7] =  "X.400";
  65.             mailers[8] =  "Mac MS";
  66.             mailers[9] =  "MMDF";
  67.             mailers[10] = "Andrew";
  68.             mailers[11] = "Columbia MM";
  69.             mailers[12] = "Unknown #1";
  70.             mailers[13] = "EasyMail";
  71.             mailers[14] = "CompuServe";
  72.             mailers[15] = "smail";
  73.             mailers[16] = "MCI Mail";
  74.             mailers[17] = "VAX MAIL(?)";
  75.             mailers[18] = "Gator Mail (?)";
  76.             mailers[19] =  "TOTAL";
  77.             max = 19;}
  78.                                       {mailer = 0;}
  79.      /^<Pine/                         {mailer = 1;}
  80.      /^<MailManager/                  {mailer = 2;}
  81.      /^<[12]?[90]?9[0-9]1?[0-9][1-3]?[0-9]+\.[AaBb][AaBb][0-9]+@/ {mailer = 3;}
  82.      /^<[0-9A-Z]+@/                   {mailer = 4;}
  83.      /^<199[0-9][A-Za-z]..[0-9]*\./   {mailer = 5;}
  84.      /@sprint.com/                    {mailer = 6;}
  85.      /\/[A-Z]*=.*\/[A-Z]*=.*/         {mailer = 7;}
  86.      /^<MacMS\.[0-9]+\.[0-9]+\.[a-z]+@/ {mailer = 8;}
  87.      /^<MAILQUEUE-[0-9]+\.[0-9]+/           {mailer = 9;}
  88.      /^<.[d-l][A-Z0-9a-z=_]+00[A-Za-z0-9_=]+@/ {mailer = 10;}
  89.      /^<CMM\.[0-9]+\.[0-9]+\.[0-9]+/    {mailer = 11 ;}
  90.      /^<9[0-9][JFMASOND][aepuco][nbrylgptvc][0-9][0-9]?\.[0-9]+[a-z]+\./ {mailer = 12;}
  91.      /^<EasyMail\.[0-9]+/               {mailer = 13;}
  92.      /@CompuServe.COM/                  {mailer = 14;}
  93.      /^<m[A-Za-z0-9].....-[0-9A-Za-z].....C@/       {mailer = 15;}
  94.      /@mcimail.com/                     {mailer = 16;}
  95.      /^<9[0-9][01][0-9][0-3][0-9][0-2][0-9][0-5][0-9][0-5][0-9].[0-9a-z]*@/ {mailer = 17;}
  96.      /^<0[0-9][0-9]+\.[0-9][0-9][0-9][0-9]+\.[0-9][0-9]+@/ {mailer=18;}
  97.  
  98.     
  99.  
  100.      '"/$domain>/"'              {campus[mailer]++; campus[max]++}
  101.      '"/$org>/"'                 {u[mailer]++; u[max]++}
  102.      '"/$host>/"'                {milton[mailer]++; milton[max]++}
  103.                                  {total[mailer]++; total[max]++}
  104.                                  {if(mailer == 0) printf("-->%s\n",$0)}
  105.      END {
  106.             for(m = 0; m <= max; m++)  {
  107.                 printf("%-10.10s", mailers[m]);
  108.                 printf(" %11d %11d %11d %11d %11d (%3d%%)\n",  milton[m], u[m] - milton[m], campus[m] -u[m], total[m] - campus[m], total[m], (total[m]*100)/total[max]);
  109.             }
  110.             printf(" ----           (%3d%%)      (%3d%%)      (%3d%%)      (%3d%%)\n", (milton[max]*100)/total[max], ((u[max] - milton[max])*100)/total[max], ((campus[max] - u[max])*100)/total[max], ((total[max] - campus[max])*100)/total[max], (u[max]*100)/total[max]);
  111.  
  112.         }' > /tmp/syslogx.$$
  113.  
  114.  
  115. echo $host $org $domain | \
  116.   awk '{printf("     %.17s %.11s %.11s  Off Campus        Total\n", $1, $2, $3)}'
  117. egrep -v 'TOTAL|----|^-->' /tmp/syslogx.$$ | sort +0.60rn 
  118. egrep  'TOTAL|----' /tmp/syslogx.$$
  119. grep  '^-->' /tmp/syslogx.$$ | sed -e 's/-->//' > other-traffic
  120. rm -f /tmp/syslogx.$$
  121.  
  122.  
  123.